﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.MountAndBlade.View.MissionViews.Singleplayer.MissionSingleplayerKillNotificationUIHandler
// Assembly: TaleWorlds.MountAndBlade.View, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 61152EB8-513B-4D4A-8AC0-0D1465C6CF6C
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\Modules\Native\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.View.dll

using TaleWorlds.Core;
using TaleWorlds.Localization;

#nullable disable
namespace TaleWorlds.MountAndBlade.View.MissionViews.Singleplayer
{
  public class MissionSingleplayerKillNotificationUIHandler : MissionView
  {
    public override void OnAgentRemoved(
      Agent affectedAgent,
      Agent affectorAgent,
      AgentState agentState,
      KillingBlow killingBlow)
    {
      base.OnAgentRemoved(affectedAgent, affectorAgent, agentState, killingBlow);
      if (!affectedAgent.IsHuman)
        return;
      string variable1 = affectorAgent == null ? string.Empty : affectorAgent.Name;
      string variable2 = affectedAgent == null ? string.Empty : affectedAgent.Name;
      uint color = 4291306250;
      Agent main = Agent.Main;
      if (main != null && (main.Team != this.Mission.SpectatorTeam && main.Team != affectedAgent.Team || affectorAgent != null && affectorAgent == main))
        color = 4281589009U;
      TextObject textObject;
      if (affectorAgent != null)
      {
        textObject = new TextObject("{=2ZarUUbw}{KILLERPLAYERNAME} has killed {KILLEDPLAYERNAME}!");
        textObject.SetTextVariable("KILLERPLAYERNAME", variable1);
      }
      else
        textObject = new TextObject("{=9CnRKZOb}{KILLEDPLAYERNAME} has died!");
      textObject.SetTextVariable("KILLEDPLAYERNAME", variable2);
      MessageManager.DisplayMessage(textObject.ToString(), color);
    }
  }
}
